package com.macllvm.whale.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.view.Window;
import android.util.Log;
import com.macllvm.whale.R;


public class CustomDialog extends Dialog {

    private Context mContext;
    private IBtnOKCallback mBtnOKCallback;
    private TextView mMessage;


    public CustomDialog(Context context) {
        super(context, R.style.CustomDialog);
        this.mContext = context;
        init();
    }
    public CustomDialog(Context context, int theme){
        super(context, theme);
        this.mContext = context;
        init();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    public void init() {
        this.setContentView(R.layout.custom_dialog);

        Window window = getWindow();
        mMessage = (TextView)window.findViewById(R.id.dialog_message);
        final Button button = (Button) window.findViewById(R.id.dialog_button_ok);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(null != mBtnOKCallback)
                    mBtnOKCallback.callback();
                dismiss();
            }
        });
    }


    public void setMessage(String msg) {
        mMessage.setText(msg);
    }

    public void setButtonOkCallback(IBtnOKCallback callback) {
        mBtnOKCallback = callback;
    }

    public interface IBtnOKCallback {
        void callback();
    }
}